// JavaScript Document

var xmlHttp

var div2
function rate(rid,action2)

{

/*if (str.length==0)

  { 

  document.getElementById("txtHint").innerHTML=""

  return

  }*/

xmlHttp=GetXmlHttpObject()

if (xmlHttp==null)

  {

  alert ("Browser does not support HTTP Request")

  return

  } 

var url="submit.php"

action = action2;
url=url+"?rid="+rid+"&action="+action2;

url=url+"&sid="+Math.random();

url = encodeURI(url); 

xmlHttp.onreadystatechange=function()
{     

     var loadingDiv = document.getElementById("loading");   

		 if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")

 { 
 alert("感谢你的评论！");
 if(action2 == "like") {
 document.getElementById("likes_count").innerHTML=xmlHttp.responseText 
 } else {
	 document.getElementById("hates_count").innerHTML=xmlHttp.responseText 
 }

 } 

}
xmlHttp.open("GET",url,true)

xmlHttp.send(null)

} 

/*function stateChanged() 

{ 

if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")

 { 

 document.getElementById("photo").innerHTML=xmlHttp.responseText 

 } 

}*/



function GetXmlHttpObject()

{

var xmlHttp=null;

try

 {

 // Firefox, Opera 8.0+, Safari

 xmlHttp=new XMLHttpRequest();

 }

catch (e)

 {

 // Internet Explorer

 try

  {

  xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");

  }

 catch (e)

  {

  xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");

  }

 }

return xmlHttp;

}



//stateChanged = function(action)    

function stateChanged(action)

{     



     //var sliderBlank = document.getElementById("sidebar");  



     // 让需要显示结果的层显示空白  



     //sliderBlank.innerHTML = " ";   



        



     // 获得loading显示层  



     var loadingDiv = document.getElementById("loading");   



     // 插入loading图  



    //loadingDiv.innerHTML = "<img src='images/loading.gif' />";   



     // 显示loading层  



     //loadingDiv.style.display = "";   



    // if(xmlReq.readyState == 4)    



     //{     



         // 数据处理完毕之后，将loading层再隐藏掉  



        // loadingDiv.style.display = "none";   



         //alert(xmlReq.responseText);  



         //document.getElementById('content2').innerHTML = xmlReq.responseText;     



         // 输出处理结果  



         //runXML(xmlReq.responseText); 

		 if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")

 { 

  //loadingDiv.style.display = "none"; 

 //document.getElementById("likes_count").innerHTML=xmlHttp.responseText 
 alert(action)

 } 



     //}     



 } 



